'''
Created on May 21, 2012
TestCase ID: Joomla_6007
Description : Kiem thu chuc nang Check-In cho mot article
@author: Vu Dao
'''
import unittest
import HTMLTestRunner
import time
from Functions.globalFunc import openWebsite, getData, closeWebsite
from Functions.loginFunc import loginWebsite
from Functions.administratorFunc import clickOnArticleManagerBtn
from Functions.articleManagerFunc import searchAArticle, selectAArticle,\
    clickOnCheckInButton, verifyCheckInArticle

# get data
userName = getData().login.username
passWord = getData().login.password
articleName = getData().article.articleName

class Joomla_6007(unittest.TestCase):


    def setUp(self):
        print "Buoc 1: Mo website"
        openWebsite(self)

    def test_Joomla_6007(self):
        print "Buoc 2: Dang nhap website voi tai khoan quyen administrator"
        loginWebsite(self,userName, passWord)
        
        print "Buoc 3: Click vao nut Article Manager"
        clickOnArticleManagerBtn(self)
        
        print "Buoc 4: Tim kiem mot Article"
        searchAArticle(self,articleName) 
        
        print "Buoc 5: Chon mot Article"
        selectAArticle(self,articleName)
    
        print "Buoc 6: Click len nut Check-In tren thanh tool bar"
        clickOnCheckInButton(self)

        print "Buoc 7: Kiem tra article da duoc Check In"
        self.assertTrue(verifyCheckInArticle(self), "Failed")
        print "Passed: Article da duoc Check-In"
    
    def tearDown(self):
        print "Buoc 8: Dong website"
        closeWebsite(self)


if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    testSuite = unittest.TestSuite()
    suite = unittest.TestLoader().loadTestsFromTestCase(Joomla_6007)
    dateTime = time.strftime('%Y%m%d_%H_%M_%S')
    buf = file("../../Report/TestResults" + "_" + dateTime + ".html",'wb')
    runner = HTMLTestRunner.HTMLTestRunner(
                    stream=buf,
                    title='Test Results',
                    description='Kiem thu chuc nang Check-In cho mot article'
                    )
    runner.run(suite)